/**
 * 定义一个给到 createStore 用的 reducer
 */

const defaultState = {
  msg: "~",
  count: 0,
};

export default function rootReducer(state = defaultState, action) {
  switch (action.type) {
    case "INCREMENT":
      return {
        ...state,
        count: state.count + 1,
      };

    case "DECREMENT":
      return {
        ...state,
        count: state.count - 1,
      };

    default:
      return state;
  }
}
